/**
 * @filename:CarModelServiceImpl 2019-01-17 14:56:43
 * @project skz  V1.3.3
 * Copyright(c) 2018 Liu,Wenzhao Co. Ltd. 
 * All right reserved. 
 */
package com.bingsum.service;

import com.bingsum.annotation.Api;
import com.bingsum.util.ApiUtil;
import com.bingsum.util.ParaData;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.beans.factory.annotation.Autowired;
import com.github.pagehelper.PageHelper;

import java.util.List;

import com.bingsum.model.CarModel;
import com.bingsum.mapper.CarModelMapper;

/**   
 *  
 * @Description:  [车辆类型]——SERVICE
 * @Author:       Liu,Wenzhao   
 * @CreateDate:   2019-01-17 14:56:43
 * @Version:      V1.3.3
 *    
 */
@Service("carModelService")
@Transactional(readOnly = true)
public class CarModelService{

    @Autowired
    private CarModelMapper carModelMapper;

    @Api
    public List<ParaData> getCarModelInfoList(ParaData pd) {
        System.out.println(pd);
        return carModelMapper.getCarModelInfoList(pd);
    }

    @Api
    public ParaData getCarModelInfo(ParaData pd){
        System.out.println(pd);
        return carModelMapper.getCarModelInfo(pd);
    }

    @Api
    @Transactional(readOnly = false)
    public Object newCarModelInfo(ParaData pd) {
        System.out.println(pd);
        CarModel carModel = pd.toBean(CarModel.class);
        if (carModel.getId() != null) {
            carModelMapper.setCarModelInfo(pd);
        } else {
            System.out.println("success");
            carModelMapper.newCarModelInfo(pd);
        }
        return ApiUtil.returnOK(pd,carModel);
    }

    @Api
    @Transactional(readOnly = false)
    public Object delCarModel(ParaData pd) {
        carModelMapper.delCarModel(pd);
        CarModel carModel = pd.toBean(CarModel.class);
        return ApiUtil.returnOK(pd,carModel.getId());
    }

    @Api
    public List<CarModel> getCarModelBriefInfo(ParaData pd) {
        return carModelMapper.getCarModelBriefInfo(pd);
    }


}